﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TransportHierarchyWithForms
{
    public enum SurfaceTransportType
    {
        TRAIN=1, BUS=2
    }

    public enum AviaTransportType
    {
        AIRPLANE=1, HELICOPTER=2
    }

    public enum TransportType
    {
        SURFACE=1, AVIA=2
    }

    public abstract class TransportFactory
    {
        public TransportFactory() { }
        public abstract Transport CreateTransport(uint type);
    }

    public class SurfaceFactory : TransportFactory
    {
        public override Transport CreateTransport(uint type)
        {
            switch (type)
            {
                case (uint)SurfaceTransportType.TRAIN: return new Train();
                case (uint)SurfaceTransportType.BUS: return new Bus();
                default: throw new ArgumentException("Invalid type.", "type");
            }
        }
    }

    public class AviaFactory : TransportFactory
    {
        public override Transport CreateTransport(uint type)
        {
            switch (type)
            {
                case (uint)AviaTransportType.AIRPLANE: return new Airplane();
                case (uint)AviaTransportType.HELICOPTER: return new Helicopter();
                default: throw new ArgumentException("Invalid type.", "type");
            }
        }
    }

}
